<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>修改密码</title>
	<link rel="stylesheet" type="text/css" href="/admin/css/bootstrap.min.css"/>
	<link rel="stylesheet" type="text/css" href="/admin/css/bootstrap-table.min.css"/>
	<link rel="stylesheet" type="text/css" href="/admin/css/style.min.css" />
	<link rel="stylesheet" type="text/css" href="/admin/layui/css/layui.css">

	<script src="/admin/js/jquery-3.3.1.min.js"></script>
	<script src="/admin/js/bootstrap.js"></script>
	<script src="/admin/layui/layui.js" charset="utf-8"></script>
	<script src="/admin/js/api.js" charset="utf-8"></script>
	<script src="/admin/js/base.js" charset="utf-8"></script>
	<script src="/admin/js/common.js"></script>

</head>
<body>
<div>
	<!-- Tab panes -->
	<div class="tab-content form-content">
		<div>
			<div class="rigthContent">
				<form class="layui-form layui-form-content" lay-filter="add_form" action="">
					<div class="tab-content form-content">
						<div class="row tab-pane active" role="tabpanel" id="form-tab1">
							<div class="col-sm-12">
								<div class="ibox float-e-margins">
									<div class="" >
                                        <div class="layui-form-item">
                                            <div class="layui-inline width-100">
                                                <label class="layui-form-label"><samp style="color: red;">*</samp>旧密码：</label>
                                                <div class="layui-input-block">
                                                    <input type="password" id="oldPass" name="oldPass" lay-verify="required" autocomplete="on" placeholder="请输入旧密码" class="layui-input">
                                                </div>
                                            </div>
                                        </div>
										<div class="layui-form-item">
											<div class="layui-inline width-100">
												<label class="layui-form-label"><samp style="color: red;">*</samp>新密码：</label>
												<div class="layui-input-block">
													<input type="password" id="newPass" name="newPass" required lay-verify="required|Password" autocomplete="on" placeholder="请输入新密码" class="layui-input">
												</div>
											</div>
										</div>
                                        <div class="layui-form-item">
                                            <div class="layui-inline width-100">
                                                <label class="layui-form-label"><samp style="color: red;">*</samp>确认新密码：</label>
                                                <div class="layui-input-block">
                                                    <input type="password" id="confirmPass" name="confirmPass" required lay-verify="required|Password" autocomplete="on" placeholder="请输入再次输入新密码" class="layui-input">
                                                </div>
                                            </div>
                                        </div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="layui-form-submit">
						<button id="save" type="button" class="layui-btn" lay-submit="" lay-filter="save" id="save">保存</button>
						<a class="layui-btn handle_back" onclick="toClose()">取消</a>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<script>
    layuiReady (function() {
        _loadingClose();
        layform.verify({
            Password: [/(.+){6,20}$/, '密码必须6到20位']
        });

        layform.on('submit(save)', function(data) {
            data = data.field; 
            var checkPassLengthT = checkPassLength(data.newPass);
            
            var checkNrePassIsEqualConfirmT = checkNrePassIsEqualConfirm(data.newPass, data.confirmPass);
            if (!(checkNrePassIsEqualConfirmT == 0)) {
            	layerMessage("两次输入密码不一致，请重新输入!");
            	return;
            }
            Layui.confirm("确定提交吗？", '', function(layer, index) {
                noSubmit();
                This.jqueryAjax(Api.admin.base.user.updataPass, data, "json", function(data) {
                    if(data.status == 1) {
                        closeFlushParent(parent);
                        parent.parent_receive(data.message);
                    } else {
                        reSubmit();
                        layerMessage(data.message, 2);
                    }
                });
            });
        });
    });
    
    //检查两次输入密码是否一致
    function checkNrePassIsEqualConfirm(newPass, confirmPass){
     	var checkNrePassIsEqualConfirmR;
    	if (!(newPass == confirmPass)) {
    		checkNrePassIsEqualConfirmR = 1;
    	} else {
    		checkNrePassIsEqualConfirmR = 0;
    	}
    	return checkNrePassIsEqualConfirmR;
    }
    
    //检查密码长度
    function checkPassLength(newPass){
    	var checkPassLengthR;
    	if (!(6 <= newPass.length <= 12)) {
    		checkPassLengthR = 1;
    	} else {
    		checkPassLengthR = 0;
    	}
    	return checkPassLengthR;
    }

</script>

</body>

</html>